/***************************************************************************
 *   Copyright (C) 2014 by Philipp Müller                                  *
 *   philipp.mueller@gmx.de                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
 ***************************************************************************/


#include <QGuiApplication>
#include <QtQuick>

#include "vompremote.h"

int main( int argc, char *argv[] )
{
    QGuiApplication app( argc, argv );
    QQmlApplicationEngine engine;

    QString locale = QLocale::system().name();

    QTranslator translator;
    translator.load( QString( ":/i18n/vompremote_" ) + locale );
    app.installTranslator( &translator );

    VompRemote *remote = new VompRemote();
    remote->setEngine( &engine );

    engine.rootContext()->setContextProperty( "VompRemote", remote );
    engine.rootContext()->setContextProperty( "MvpList",  remote->mvpListModel() );
    engine.rootContext()->setContextProperty( "ChannelListModel", remote->channelListModel() );
    engine.rootContext()->setContextProperty( "TimerListModel", remote->timerListModel() );

    engine.load( QUrl( "qrc:/qml/VompRemote/main.qml" ) );
    engine.addImportPath( "qrc:/qml/VompRemote/content" );

    QObject *topLevel = engine.rootObjects().value( 0 );
    QQuickWindow *window = qobject_cast<QQuickWindow *>( topLevel );

    remote->setRootObject( topLevel );

    if ( !window ) {
        qWarning( "Main Error: Your root item has to be a Window." );
        return -1;
    }
    window->show();

//    window->showMaximized();
    return app.exec();
}

